//引入L7控件
import { Fullscreen, Zoom, MouseLocation, Scale, MapTheme } from '@antv/l7'
//导入app.vue组件导出的L7场景实例

//定义存放控件的对象
const controls = {}
//定义添加控件的方法
function useControl(scene, map) {
  //添加全屏控件
  controls.fullscreen = new Fullscreen({
    btnText: '全屏',
    exitBtnText: '退出全屏',
  })
  //添加缩放控件
  controls.zoom = new Zoom({
    //位置在右侧中间
    position: 'rightcenter',
    zoomSpeed: 1.2,
  })
  //添加鼠标位置控件
  controls.mouseLocation = new MouseLocation({
    position: 'bottomleft',
    content: '鼠标位置：{x}, {y}',
  })
  //添加地图主题控件
  controls.mapTheme = new MapTheme({
    options: [
      {
        text: '白天',
        value: 'mapbox://styles/mapbox/standard',
        img: '/themes/navigation-day-v1.png',
      },
      {
        text: '黑夜',
        value: 'mapbox://styles/mapbox/dark-v10',
        img: '/themes/navigation-night-v1.png',
      },
      {
        text: '卫星',
        value: 'mapbox://styles/mapbox/satellite-v9',
        img: '/themes/satellite-v9.png',
      },
      {
        text: '标记',
        value: 'mapbox://styles/mapbox/satellite-streets-v12',
        img: '/themes/satellite-streets-v12.png',
      },
    ],
  })
  //遍历存放控件对象，添加到场景中
  for (let key in controls) {
    scene.addControl(controls[key])
  }
}
export default useControl
